HWJ4 - Using the scanner class: (This counts as
2 hws)
Start with the code below and use it to create the 9 methods described.
/*
* @author Jeff Borland -> Replace w/ your name
* @date 10-26-10
*/
import java.util.Scanner;
public class HWJ4
{
//Ask for a weight in ounces and convert it to grams.
public void convertToGrams()
{
//You will need the following line in all methods in order to initialize the scanner.
Scanner scan=new Scanner(System.in); //The Scanner constructor requires the use of the io class
//add your code here
}
//Ask for a number of meters and convert to feet.
public void convertToFeet()
{
//You will need the following line in all methods in order to initialize the scanner.
Scanner scan=new Scanner(System.in); //The Scanner constructor requires the use of the io class
//add your code here
}
//Ask the user for a number of miles for a taxi ride and then spit out total cost
//Our company charges $3.25 to pick you up plus $1.25 per mile.
public void findTaxiCost()
{
//You will need the following line in all methods in order to initialize the scanner.
Scanner scan=new Scanner(System.in); //The Scanner constructor requires the use of the io class
//add your code here
}
//Ask the user for a number of miles for a taxi ride and then ask for
// cost per mile and pickup cost.
//Then spit out total charge (which is #of miles *cost per mile + pickup cost
public void findTaxiCostV2()
{
//You will need the following line in all methods in order to initialize the scanner.
Scanner scan=new Scanner(System.in); //The Scanner constructor requires the use of the io class
//add your code here
}
}
|